var CheckVaildUtil = {
  checkNullValue: function (fields, obj, getErrorFun) {
    var $alert = Vue.prototype.$alert;
    for (var i = 0; i < fields.length; i++) {
      var field = fields[i];
      var value = obj[field];
      if (value === undefined || value === null) {
        var msg = getErrorFun(field);
        $alert(msg, '提示');
        return false;
      }

      var type = typeof value;
      if (type === 'string') {
        value = value.trim();
        if (value === '') {
          var msg = getErrorFun(field);
          $alert(msg, '提示');
          return false;
        }
      } else if (type === 'number') {
        if (_.isNaN(value)) {
          var msg = getErrorFun(field);
          $alert(msg, '提示');
          return false;
        }
      } else {
        if (_.isArray(value)) {
          if (value.length === 0) {
            var msg = getErrorFun(field);
            $alert(msg, '提示');
            return false;
          }
        }
      }
    }
    return true;
  },

  checkNullField:function(fields, obj){
    for (var i = 0; i < fields.length; i++) {
      var field = fields[i];
      var value = obj[field];
      if (value === undefined || value === null) {
        return field;
      }

      var type = typeof value;
      if (type === 'string') {
        value = value.trim();
        if (value === '') {
          return field;
        }
      } else if (type === 'number') {
        if (_.isNaN(value)) {
          return field;
        }
      } else {
        if (_.isArray(value)) {
          if (value.length === 0) {
            return field;
          }
        }
      }
    }
    return '';
  }
};